#pragma once

#include "CallEvent.h"

#include "Operation.h"

namespace uml {

CallEvent::CallEvent(const QString& umlType)
    : MessageEvent(umlType) {}

void CallEvent::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    MessageEvent::fromJson(json, errorList);
    operation_ = JsonSerializable::create<Operation>(json.value("operation"), errorList);

}

void CallEvent::toJson(QJsonObject& json) {
    MessageEvent::toJson(json);
    if (operation_) {
        QJsonObject operation_json;
        operation_->toJson(operation_json);
        json.insert("operation", operation_json);
    }
}

/// <summary>
/// operation getter
/// Designates the Operation whose invocation raised the CalEvent.
/// </summary>
shared_ptr<Operation> CallEvent::operation() const {
    return operation_;
}

/// <summary>
/// operation setter
/// Designates the Operation whose invocation raised the CalEvent.
/// </summary>
void CallEvent::setOperation(shared_ptr<Operation> value) {
    operation_ = value;
}

} // namespace uml
